//
//  PersonInformationCell.m
//  mendianjieke
//
//  Created by 响当当 on 8/2/19.
//  Copyright © 2019 dongzheng. All rights reserved.
//

#import "PersonInformationCell.h"

@interface PersonInformationCell()
@property (nonatomic, strong)UILabel *serviceTimeLabel;//服务时长
@property (nonatomic, strong)UILabel *customerDetailLabel;//客户成交数
@property (nonatomic, strong)UILabel *customerDealLabel;//成交金额
@property (nonatomic, strong)UILabel *customerPriceLabel;//客户单价
@property (nonatomic, strong)UILabel *personSwitchLabel;//个人转化率
@property (nonatomic, strong)UILabel *personContributeLabel;//个人贡献
@end

@implementation PersonInformationCell


- (UILabel *)serviceTimeLabel
{
    if (!_serviceTimeLabel)
    {
        UILabel *titleLabel = [Utilties creatLabelWithFrame:CGRectMake(10*kUIScaleBasePlus,15*kUIScaleBasePlus,90*kUIScaleBasePlus,17*kUIScaleBasePlus)
                                               textAligment:NSTextAlignmentCenter
                                                   textClor:LCHexColor(0x989898)
                                                   textFont:12*kUIScaleBasePlus];
        titleLabel.text = @"个人总服务时长";
        [self.contentView addSubview:titleLabel];
        
        _serviceTimeLabel = [Utilties creatLabelWithFrame:CGRectMake(0,CGRectGetMaxY(titleLabel.frame)+10*kUIScaleBasePlus,113*kUIScaleBasePlus,21*kUIScaleBasePlus)
                                             textAligment:NSTextAlignmentCenter
                                                 textClor:LCHexColor(0x282828)
                                                 textFont:15*kUIScaleBasePlus];
        _serviceTimeLabel.numberOfLines = 0;
        _serviceTimeLabel.text = @"5367小时";
        
        UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(112*kUIScaleBasePlus,27*kUIScaleBasePlus,1*kUIScaleBasePlus,25*kUIScaleBasePlus)];
        lineView.backgroundColor = LCHexColor(0xE5E5E5);
        [self.contentView addSubview:lineView];
    }
    return _serviceTimeLabel;
}

- (UILabel *)customerDetailLabel
{
    if (!_customerDetailLabel)
    {
        UILabel *titleLabel = [Utilties creatLabelWithFrame:CGRectMake(SCREEN_WIDTH/2-66.5*kUIScaleBasePlus,15*kUIScaleBasePlus,113*kUIScaleBasePlus,17*kUIScaleBasePlus)
                                               textAligment:NSTextAlignmentCenter
                                                   textClor:LCHexColor(0x989898)
                                                   textFont:12*kUIScaleBasePlus];
        titleLabel.text = @"个人总成交客户数";
        [self.contentView addSubview:titleLabel];
        
        _customerDetailLabel = [Utilties creatLabelWithFrame:CGRectMake(SCREEN_WIDTH/2-66.5*kUIScaleBasePlus,CGRectGetMaxY(titleLabel.frame)+10*kUIScaleBasePlus,113*kUIScaleBasePlus,21*kUIScaleBasePlus)
                                             textAligment:NSTextAlignmentCenter
                                                 textClor:LCHexColor(0x282828)
                                                 textFont:15*kUIScaleBasePlus];
        _customerDetailLabel.numberOfLines = 0;
        _customerDetailLabel.text = @"562人";

        UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(243*kUIScaleBasePlus,27*kUIScaleBasePlus,1*kUIScaleBasePlus,25*kUIScaleBasePlus)];
        lineView.backgroundColor = LCHexColor(0xE5E5E5);
        [self.contentView addSubview:lineView];
    }
    return _customerDetailLabel;
}

- (UILabel *)customerDealLabel
{
    if (!_customerDealLabel)
    {
        UILabel *titleLabel = [Utilties creatLabelWithFrame:CGRectMake(CGRectGetMaxX(self.customerDetailLabel.frame)+17*kUIScaleBasePlus,15*kUIScaleBasePlus,90*kUIScaleBasePlus,17*kUIScaleBasePlus)
                                               textAligment:NSTextAlignmentCenter
                                                   textClor:LCHexColor(0x989898)
                                                   textFont:12*kUIScaleBasePlus];
        titleLabel.text = @"个人总成交金额";
        [self.contentView addSubview:titleLabel];
        
        _customerDealLabel = [Utilties creatLabelWithFrame:CGRectMake(CGRectGetMaxX(self.customerDetailLabel.frame)+12*kUIScaleBasePlus,CGRectGetMaxY(titleLabel.frame)+10*kUIScaleBasePlus,113*kUIScaleBasePlus,21*kUIScaleBasePlus)
                                                textAligment:NSTextAlignmentCenter
                                                    textClor:LCHexColor(0x282828)
                                                    textFont:15*kUIScaleBasePlus];
        _customerDealLabel.numberOfLines = 0;
        _customerDealLabel.text = @"287287元";
    }
    return _customerDealLabel;
}

- (UILabel *)customerPriceLabel
{
    if (!_customerPriceLabel)
    {
        UILabel *titleLabel = [Utilties creatLabelWithFrame:CGRectMake(10*kUIScaleBasePlus,93*kUIScaleBasePlus,90*kUIScaleBasePlus,17*kUIScaleBasePlus)
                                               textAligment:NSTextAlignmentCenter
                                                   textClor:LCHexColor(0x989898)
                                                   textFont:12*kUIScaleBasePlus];
        titleLabel.text = @"个人客户单价";
        [self.contentView addSubview:titleLabel];
        
        _customerPriceLabel = [Utilties creatLabelWithFrame:CGRectMake(0,CGRectGetMaxY(titleLabel.frame)+10*kUIScaleBasePlus,113*kUIScaleBasePlus,21*kUIScaleBasePlus)
                                                textAligment:NSTextAlignmentCenter
                                                    textClor:LCHexColor(0x282828)
                                                    textFont:15*kUIScaleBasePlus];
        _customerPriceLabel.numberOfLines = 0;
        _customerPriceLabel.text = @"237823元";
        
        UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(112*kUIScaleBasePlus,105*kUIScaleBasePlus,1*kUIScaleBasePlus,25*kUIScaleBasePlus)];
        lineView.backgroundColor = LCHexColor(0xE5E5E5);
        [self.contentView addSubview:lineView];
    }
    return _customerPriceLabel;
}

- (UILabel *)personSwitchLabel
{
    if (!_personSwitchLabel)
    {
        UILabel *titleLabel = [Utilties creatLabelWithFrame:CGRectMake(SCREEN_WIDTH/2-66.5*kUIScaleBasePlus,93*kUIScaleBasePlus,113*kUIScaleBasePlus,17*kUIScaleBasePlus)
                                               textAligment:NSTextAlignmentCenter
                                                   textClor:LCHexColor(0x989898)
                                                   textFont:12*kUIScaleBasePlus];
        titleLabel.text = @"个人总转化率";
        [self.contentView addSubview:titleLabel];
        
        _personSwitchLabel = [Utilties creatLabelWithFrame:CGRectMake(SCREEN_WIDTH/2-66.5*kUIScaleBasePlus,CGRectGetMaxY(titleLabel.frame)+10*kUIScaleBasePlus,113*kUIScaleBasePlus,21*kUIScaleBasePlus)
                                               textAligment:NSTextAlignmentCenter
                                                   textClor:LCHexColor(0x282828)
                                                   textFont:15*kUIScaleBasePlus];
        _personSwitchLabel.numberOfLines = 0;
        _personSwitchLabel.text = @"44%";
        
        UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(243*kUIScaleBasePlus,105*kUIScaleBasePlus,1*kUIScaleBasePlus,25*kUIScaleBasePlus)];
        lineView.backgroundColor = LCHexColor(0xE5E5E5);
        [self.contentView addSubview:lineView];
    }
    return _personSwitchLabel;
}

- (UILabel *)personContributeLabel
{
    if (!_personContributeLabel)
    {
        UILabel *titleLabel = [Utilties creatLabelWithFrame:CGRectMake(CGRectGetMaxX(self.personSwitchLabel.frame)+17*kUIScaleBasePlus,93*kUIScaleBasePlus,90*kUIScaleBasePlus,17*kUIScaleBasePlus)
                                               textAligment:NSTextAlignmentCenter
                                                   textClor:LCHexColor(0x989898)
                                                   textFont:12*kUIScaleBasePlus];
        titleLabel.text = @"个人天贡献";
        [self.contentView addSubview:titleLabel];
        
        _personContributeLabel = [Utilties creatLabelWithFrame:CGRectMake(CGRectGetMaxX(self.personSwitchLabel.frame)+12*kUIScaleBasePlus,CGRectGetMaxY(titleLabel.frame)+10*kUIScaleBasePlus,113*kUIScaleBasePlus,21*kUIScaleBasePlus)
                                              textAligment:NSTextAlignmentCenter
                                                  textClor:LCHexColor(0x282828)
                                                  textFont:15*kUIScaleBasePlus];
        _personContributeLabel.numberOfLines = 0;
        _personContributeLabel.text = @"2872元/天";
        
    }
    return _personContributeLabel;
}

- (void)setFrame:(CGRect)frame
{
    frame.origin.x += 10*kUIScaleBasePlus;
    
    frame.size.width -= 2 * 10*kUIScaleBasePlus;
        
    [super setFrame:frame];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.layer.cornerRadius = 10;
        self.layer.masksToBounds = YES;
        
        [self.contentView addSubview:self.serviceTimeLabel];
        [self.contentView addSubview:self.customerDetailLabel];
        [self.contentView addSubview:self.customerDealLabel];
        [self.contentView addSubview:self.customerPriceLabel];
        [self.contentView addSubview:self.personSwitchLabel];
        [self.contentView addSubview:self.personContributeLabel];
        
        UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(15*kUIScaleBasePlus,78*kUIScaleBasePlus,330*kUIScaleBasePlus,1*kUIScaleBasePlus)];
        lineView.backgroundColor = LCHexColor(0xEFEFEF);
        [self.contentView addSubview:lineView];
    }
    return self;
}

- (void)setModel:(UserInfoModel *)model
{
    _model = model;
    self.serviceTimeLabel.text = [NSString stringWithFormat:@"%@小时",model.totalTime.stringValue];
    
    self.customerDetailLabel.text = [NSString stringWithFormat:@"%@人",model.totalCustomer.stringValue];
    
    self.customerDealLabel.text = [NSString stringWithFormat:@"%@人",model.totalAmount.stringValue];
    
    CGFloat customerPrice = model.totalAmount.floatValue/model.totalPayCustomer.floatValue;
    self.customerPriceLabel.text = [NSString stringWithFormat:@"%.1f元",customerPrice];
    
    CGFloat switchs = (model.totalPayCustomer.floatValue/model.totalCustomer.floatValue)*100;
    self.personSwitchLabel.text = [NSString stringWithFormat:@"%ld%%",(long)switchs];
    
    NSInteger day = model.totalAmount.integerValue/model.totalDays.integerValue;
    self.personContributeLabel.text = [NSString stringWithFormat:@"%ld元/天",day];

}
@end
